package com.pg.free.app;

import com.badlogic.gdx.Application;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.pg.free.screen.GameScreen;
import com.pg.free.screen.LogoScreen;
import com.pg.free.util.Const;
import com.pg.free.util.Context;
import com.pg.free.util.Logger;

public class GameApp extends Game {

	private OrthographicCamera camera;
	private SpriteBatch batch;

	@Override
	public void create() {
		Gdx.app.setLogLevel(Application.LOG_DEBUG);
		this.camera = new OrthographicCamera();
		this.camera.setToOrtho(false, Const.viewWidth, Const.viewHeight);
		this.batch = new SpriteBatch();
		batch.setProjectionMatrix(camera.combined);
		Context.game = this;
		this.setCurrentScreen(new LogoScreen());
	}

	public void setCurrentScreen(GameScreen gameScreen) {
		gameScreen.setBatch(this.batch);
		super.setScreen(gameScreen);
	}

	@Override
	public void dispose() {
		super.dispose();
		this.batch.dispose();
		Logger.debug("Free.batch", "dispose");
	}
}
